update

FFIB 10 часов назад
Родитель
Сommit
d367555504
1 измененных файлов с 3 добавлено и 2 удалено
  1. 3 2
      sales/models.py

+ 3 - 2
sales/models.py

@@ -7,6 +7,7 @@ from django_models_ext import BaseModelMixin, upload_file_url, upload_path
7 7
 from shortuuidfield import ShortUUIDField
8 8
 
9 9
 from datetime import datetime
10
+from django.utils import timezone
10 11
 
11 12
 
12 13
 class SalesResponsibilityInfo(BaseModelMixin):
@@ -186,8 +187,8 @@ class LotteryCampaignInfo(BaseModelMixin):
186 187
         return u'{}'.format(self.title or self.campaign_id or '')
187 188
 
188 189
     def is_active(self):
189
-        return self.start_at and self.end_at and self.start_at <= datetime.now() <= self.end_at
190
-
190
+        now = timezone.now()          # ← aware,和 DB 值可比
191
+        return bool(self.start_at and self.end_at and self.start_at <= now <= self.end_at)
191 192
     @property
192 193
     def data(self):
193 194
         return {